package cn.itcast.user.service;

import cn.itcast.user.mapper.UserMapper;
import cn.itcast.user.pojo.User;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class UserService {

    @Autowired
    private UserMapper userMapper;
    @Autowired
    private RestTemplate restTemplate;
/**
 * @File    :   UserService
 * @Time    :   2021/9/28 8:39 上午
 * @Author  :   Zhang Hong
 * @Version :   1.0
 * @Contact :   zh224635@163.com
 * @Desc    :   TODO  新增查询用户id时，查询该用户所有订单信息
 **/

    public User queryById(Long id) {
        String url = "http://orderservice/order/random";
        Integer random = restTemplate.getForObject(url, Integer.class);
        User user = userMapper.findById(id);
        user.setId(id + random);
        return user;

    }
}